

<%@ page import="fi.hell.lunchit.Restaurant" %>
<%@ page import="fi.hell.lunchit.RestaurantTag" %>
<%@ page import="fi.hell.enums.Day" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'restaurant.label', default: 'Restaurant')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${restaurantInstance}">
            <div class="errors">
                <g:renderErrors bean="${restaurantInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post"  enctype="multipart/form-data">
                <g:hiddenField name="id" value="${restaurantInstance?.id}" />
                <g:hiddenField name="version" value="${restaurantInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="name"><g:message code="restaurant.name.label" default="Name" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" value="${restaurantInstance?.name}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address"><g:message code="restaurant.address.label" default="Address" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'address', 'errors')}">
                                    <g:textField name="address" value="${restaurantInstance?.address}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="zip"><g:message code="restaurant.zip.label" default="Zip" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'zip', 'errors')}">
                                    <g:textField name="zip" value="${restaurantInstance?.zip}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="city"><g:message code="restaurant.city.label" default="City" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'city', 'errors')}">
                                    <g:textField name="city" value="${restaurantInstance?.city}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="homePage"><g:message code="restaurant.homePage.label" default="Home Page" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'homePage', 'errors')}">
                                    <g:textField name="homePage" value="${restaurantInstance?.homePage}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="logo"><g:message code="restaurant.logo.label" default="Logo" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'logo', 'errors')}">
                                    <input type="file" id="logo" name="logo" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="openingDays"><g:message code="restaurant.openingDays.label" default="Opening Days" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'openingDays', 'errors')}">
                                    <input type="checkbox" name="openingDays" value="${Day.MONDAY}" ${restaurantInstance.openingDays?.contains(Day.MONDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.MONDAY" default="Monday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.TUESDAY}" ${restaurantInstance.openingDays?.contains(Day.TUESDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.TUESDAY" default="Tuesday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.WEDNESDAY}" ${restaurantInstance.openingDays?.contains(Day.WEDNESDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.WEDNESDAY" default="Wednesday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.THURSDAY}" ${restaurantInstance.openingDays?.contains(Day.THURSDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.THURSDAY" default="Thursday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.FRIDAY}" ${restaurantInstance.openingDays?.contains(Day.FRIDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.FRIDAY" default="Friday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.SATURDAY}" ${restaurantInstance.openingDays?.contains(Day.SATURDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.SATURDAY" default="Saturday" /><br />
                                    <input type="checkbox" name="openingDays" value="${Day.SUNDAY}" ${restaurantInstance.openingDays?.contains(Day.SUNDAY) ? 'checked="checked"' : ''} />
                                    <g:message code="day.SUNDAY" default="Sunday" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="homePage"><g:message code="restaurant.tags.label" default="Tags" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: restaurantInstance, field: 'tags', 'errors')}">
                                    <g:each in="${RestaurantTag.list()}">
	                                    <input type="checkbox" name="tags" value="${it.id}" ${restaurantInstance.tags?.contains(it) ? 'checked="checked"' : ''} />
	                                    <g:message code="restaurantTag.${it.name}" /><br />
	                                </g:each>
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>